//
//  FirstCollectionCell.m
//  BuffetNews
//
//  Created by 李荃荃 on 14-10-27.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "FirstCollectionCell.h"
#import "WebColor.h"
@implementation FirstCollectionCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.myImage = [[UIImageView alloc] init];
        [self.contentView addSubview:_myImage];
        [_myImage release];
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:_title];
        [_title release];
        
        
        //  长按手势
        UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)];
        longPress.minimumPressDuration = 0.7;  //  用户至少长按0.7秒的时候启动长按的方法
        longPress.allowableMovement = 20;    //  允许用户长按的时候20像素的滑动范围
        
        [self addGestureRecognizer:longPress];
        [longPress addTarget:self action:@selector(longPressAction:)];
        [longPress release];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _myImage.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 5 * 4);
    _myImage.layer.cornerRadius = 20;
    
    _title.frame = CGRectMake(0, self.contentView.frame.size.height / 5 * 3, self.contentView.frame.size.width, self.contentView.frame.size.height / 5);
    _title.textAlignment = NSTextAlignmentCenter;
    _title.font = [UIFont systemFontOfSize:12];
    _title.lineBreakMode = NSLineBreakByTruncatingMiddle;
    
}

- (void)longPressAction:(UILongPressGestureRecognizer *)longPerss
{
    if (longPerss.state == UIGestureRecognizerStateBegan) {
        [self.target performSelector:_action withObject:self];
    }
}





- (void)dealloc
{
    [_myImage release];
    [_title release];
    [super dealloc];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
